package com.dd.stack.file.config.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

import java.util.ArrayList;

/**
 * @Author liuxianmeng
 * @CreateTime 2025/4/1 1:28
 * @Description SwaggerConfig
 */
@Configuration
@EnableSwagger2WebMvc
public class SwaggerConfig {
    @Bean
    public Docket docket(Environment environment){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo()) // 配置apiInfo信息
                .enable(true) // enable是否启动了Swagger 如果是False 则Swagger不能在浏览器中访问
                .select()
                // 需要生成的api信息的Controller包 目前还没有写Controller类 当前为空
                .apis(RequestHandlerSelectors.basePackage("com.dd.stack.file.controller"))
                //.paths(PathSelectors.ant("/qi/**"))
                .build();
    }
    // 配置Swagger信息
    private ApiInfo apiInfo(){
        //作者信息
        Contact contact = new Contact("BigBigMeng", "https://bigbigmeng.cloud", "2751187368@qq.com");
        return new ApiInfo("文件操作 API文档",
                "文件操作 API文档",
                "v1.0", "urn:tos",
                contact, "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }
}
